package RKUjava.lang;

/** This class replaces the Double class defined by Sun. <br>
The main difference between Double and RKUDouble is that RKUDouble 
support setting the value of the wrapped <tt>int</tt>. The main use of this
is the following. Suppose you have an Double object referenced by many other
object and you want to change the value of the Double. This can't be done
with Suns Double because it doesn't support setting the value.
<br><br>
<b> Implementation details:</b><br>
<ul>
<li>Since Suns Double class is final it can't be extended. Instead RKUDouble
extends the Number class. 
<li>The class implements the same
methods as Suns Double class. These methods are implemented by calling
the methods in the Double class, i.e. they do exactly the same.
</ul>
@author Rasmus K. Ursem, <a href="mailto:ursem@daimi.au.dk">ursem@daimi.au.dk</a>
*/
public class RKUDouble extends Number
{

  /** 
    @serial
  */
  private double val;

  public RKUDouble(double value)
    {
      super();
      val = value;
    }

  /** Returns the value of the specified number as a byte. */
  public byte byteValue() 
    {
      return (byte)val;
    }

  /** Returns the value of the specified number as a double. */
  public double doubleValue() 
    {
      return (double)val;
    }

  /** Returns the value of the specified number as a float. */
  public float floatValue() 
    {
      return (float)val;
    }
  /** Returns the value of the specified number as an int. */
  public int intValue() 
    {
      return (int)val;
    }

  /** Returns the value of the specified number as a long. */
  public long longValue() 
    {
      return (long)val;
    }

  /** Returns the value of the specified number as a short. */
  public short shortValue() 
    {
      return (short)val;
    }

  /** Set the value of this RKUDouble. */
  public void setValue(double newvalue)
    {
      val = newvalue;
    };

  /** Add a value to this RKUDouble. */
  public void addValue(double value)
    {
      val = val+value;
    }

  /** Subtract a value from this RKUDouble. */
  public void subValue(double value)
    {
      val = val-value;
    }

  /** Multiply this RKUDouble by <tt>value</tt>. */
  public void multValue(double value)
    {
      val = val*value;
    }

  /** Devide this RKUDouble by <tt>value</tt>. NOTE: divValue does not throw
   exceptions if <tt>value</tt> is zero but the Java VM does. */
  public void divValue(double value)
    {
      val = val/value;
    }

  /* To be implemented
  decode(String) 
  equals(Object) 
  getInteger(String) 
  getInteger(String, int) 
  getInteger(String, Integer) 
  hashCode() 
  parseInt(String) 
  parseInt(String, int) 
  toBinaryString(int) 
  toHexString(int) 
  toOctalString(int) 
  toString() 
  toString(int) 
  toString(int, int) 
  valueOf(String) 
  valueOf(String, int) 
  */
}





